#include <cstdlib>
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include "minIni.h"
#include "config.h"
#include "resources.h"
#include "map.h"
#include "spriteanimator.h"
#include "sprite.h"

using namespace Oribi;

static const char *spriteSheetFileNames[Resources::nSpriteSheets] =
    {"res/tex/tiles.png",
     "res/char/human/male/spritesheet.png",
     "res/char/oribi/male/spritesheet.png"};

Resources::Resources()
{
    for (int i = 0; i < nSpriteSheets; ++i)
    {
        spriteSheets[i] = NULL;
    }
}

int Resources::initialise(ConfContext& conf)
{
    for (int i = 0; i < nSpriteSheets; ++i)
    {
        spriteSheets[i] = IMG_Load(spriteSheetFileNames[i]);
        if (!spriteSheets[i])
            return i + 1;
    }
    return 0;
}

SDL_Surface *Resources::getSpriteSheet(int i)
{
    if (i >= nSpriteSheets || i < 0)
        return NULL;
    return spriteSheets[i];
}
